Functional programming - Wikipedia

Functional programming

In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a declarative programming paradigm in which function definitions are trees of expressions that map values to other values, rather than a sequence of imperative statements which update the running state of the program.

In functional programming, functions are treated as first-class entities, meaning that they can be bound to names (including local identifiers), passed as arguments, and returned from other functions, just as any other data type can. This allows programs to be written in a declarative and composable style, where small functions are combined in a modular manner.

Functional programming is sometimes treated as synonymous with purely functional programming, a subset of functional programming that treats all functions as deterministic mathematical functions, or pure functions. When a pure function is called with some given arguments, it will always return the same result, and cannot be affected by any mutable state or other side effects. This is in contrast with impure procedures, common in imperative programming, which can have side effects (such as modifying the program’s state or taking input from a user). Proponents of purely functional programming claim that by restricting side effects, programs can have fewer bugs, be easier to debug and test, and be more suited to formal verification.12

Functional programming has its roots in academia, evolving from the lambda calculus, a formal system of computation based only on functions. Functional programming has historically been less popular than imperative programming, but many functional languages are seeing use today in industry and education, including Common Lisp, Scheme,3456 Clojure, Wolfram Language,78 Racket,9 Erlang,101112 Elixir,13 OCaml,1415 Haskell,1617 and F#.1819 Lean is a functional programming language commonly used for verifying mathematical theorems.20 Functional programming is also key to some languages that have found success in specific domains, like JavaScript in the Web,21 R in statistics,2223 J, K and Q in financial analysis, and XQuery/XSLT for XML.2425 Domain-specific declarative languages like SQL and Lex/Yacc use some elements of functional programming, such as not allowing mutable values.26 In addition, many other programming languages support programming in a functional style or have implemented features from functional programming, such as D27 (since 2007 with the release of D2), C++ (since C++11), C#,28 Kotlin,29 Perl,30 PHP,31 Python,32 Go,33 Rust,34 Raku,35 Scala,36 and Java (since Java 8).37

Printed 2026-10-25.

(echo:: @ ᯤ)

Footnotes

  1. Hudak, Paul (September 1989). “Conception, evolution, and application of functional programming languages” (PDF). ACM Computing Surveys. 21 (3): 359–411. doi:10.1145/72551.72554. S2CID 207637854. Archived from the original (PDF) on 2016-01-31. Retrieved 2013-08-10. ↩

  2. Hughes, John (1984). “Why Functional Programming Matters”. ↩

  3. Clinger, Will (1987). “MultiTasking and MacScheme”. MacTech. 3 (12). Retrieved 2008-08-28. ↩

  4. Hartheimer, Anne (1987). “Programming a Text Editor in MacScheme+Toolsmith”. MacTech. 3 (1). Archived from the original on 2011-06-29. Retrieved 2008-08-28. ↩

  5. Kidd, Eric. Terrorism Response Training in Scheme. CUFP 2007. Archived from the original on 2010-12-21. Retrieved 2009-08-26. ↩

  6. Cleis, Richard. Scheme in Space. CUFP 2006. Archived from the original on 2010-05-27. Retrieved 2009-08-26. ↩

  7. “Wolfram Language Guide: Functional Programming”. 2015. Retrieved 2015-08-24. ↩

  8. “Functional vs. Procedural Programming Language”. Department of Applied Math. University of Colorado. Archived from the original on 2007-11-13. Retrieved 2006-08-28. ↩

  9. “State-Based Scripting in Uncharted 2” (PDF). Archived from the original (PDF) on 2012-12-15. Retrieved 2011-08-08. ↩

  10. “Who uses Erlang for product development?”. Frequently asked questions about Erlang. Retrieved 2018-04-27. ↩

  11. Armstrong, Joe (June 2007). “A history of Erlang”. Proceedings of the third ACM SIGPLAN conference on History of programming languages. Third ACM SIGPLAN Conference on History of Programming Languages. San Diego, California. doi:10.1145/1238844.1238850. ISBN 9781595937667. ↩

  12. Larson, Jim (March 2009). “Erlang for concurrent programming”. Communications of the ACM. 52 (3): 48. doi:10.1145/1467247.1467263. S2CID 524392. ↩

  13. “The Elixir Programming Language”. Retrieved 2021-02-14. ↩

  14. Minsky, Yaron; Weeks, Stephen (July 2008). “Caml Trading — experiences with functional programming on Wall Street”. Journal of Functional Programming. 18 (4): 553–564. doi:10.1017/S095679680800676X. S2CID 30955392. ↩

  15. Leroy, Xavier. Some uses of Caml in Industry (PDF). CUFP 2007. Archived from the original (PDF) on 2011-10-08. Retrieved 2009-08-26. ↩

  16. “Haskell in industry”. Haskell Wiki. Retrieved 2009-08-26. Haskell has a diverse range of use commercially, from aerospace and defense, to finance, to web startups, hardware design firms and lawnmower manufacturers. ↩

  17. Hudak, Paul; Hughes, J.; Jones, S. P.; Wadler, P. (June 2007). A history of Haskell: being lazy with class. Third ACM SIGPLAN Conference on History of Programming Languages. San Diego, California. doi:10.1145/1238844.1238856. Retrieved 2013-09-26. ↩

  18. Mansell, Howard (2008). Quantitative Finance in F#. CUFP 2008. Archived from the original on 2015-07-08. Retrieved 2009-08-29. ↩

  19. Peake, Alex (2009). The First Substantial Line of Business Application in F#. CUFP 2009. Archived from the original on 2009-10-17. Retrieved 2009-08-29. ↩

  20. de Moura, Leonardo; Ullrich, Sebastian (July 2021). “The Lean 4 Theorem Prover and Programming Language”. Lecture Notes in Artificial Intelligence. Conference on Automated Deduction. Vol. 12699. pp. 625–635. doi:10.1007/978-3-030-79876-5_37. ISSN 1611-3349. ↩

  21. Banz, Matt (2017-06-27). “An introduction to functional programming in JavaScript”. Opensource.com. Retrieved 2021-01-09. ↩

  22. “The useR! 2006 conference schedule includes papers on the commercial use of R”. R-project.org. 2006-06-08. Retrieved 2011-06-20. ↩

  23. Chambers, John M. (1998). Programming with Data: A Guide to the S Language. Springer Verlag. pp. 67–70. ISBN 978-0-387-98503-9. ↩

  24. Novatchev, Dimitre. “The Functional Programming Language XSLT — A proof through examples”. Retrieved May 27, 2006. ↩

  25. Mertz, David. “XML Programming Paradigms (part four): Functional Programming approached to XML processing”. IBM developerWorks. Retrieved May 27, 2006. ↩

  26. Chamberlin, Donald D.; Boyce, Raymond F. (1974). “SEQUEL: A structured English query language”. Proceedings of the 1974 ACM SIGFIDET: 249–264. ↩

  27. “Functional programming - Dlang Tour”. tour.dlang.org. Retrieved 2026-07-28. ↩

  28. Functional Programming with C# - Simon Painter - NDC Oslo 2020, 8 August 2021, archived from the original on 2021-10-30, retrieved 2021-10-23 ↩

  29. “Functional programming - Kotlin Programming Language”. Kotlin. Retrieved 2019-05-01. ↩

  30. Dominus, Mark J. (2005). Higher-Order Perl. Morgan Kaufmann. ISBN 978-1-55860-701-9. ↩

  31. Holywell, Simon (2014). Functional Programming in PHP. php[architect]. ISBN 9781940111056. ↩

  32. The Cain Gang Ltd. “Python Metaclasses: Who? Why? When?” (PDF). Archived from the original (PDF) on 30 May 2009. Retrieved 27 June 2009. ↩

  33. “GopherCon 2020: Dylan Meeus - Functional Programming with Go”. YouTube. 22 December 2020. ↩

  34. “Functional Language Features: Iterators and Closures - The Rust Programming Language”. doc.rust-lang.org. Retrieved 2021-01-09. ↩

  35. Vanderbauwhede, Wim (18 July 2020). “Cleaner code with functional programming”. Archived from the original on 28 July 2020. Retrieved 6 October 2020. ↩

  36. “Effective Scala”. Scala Wiki. Archived from the original on 2012-06-19. Retrieved 2012-02-21. Effective Scala. ↩

  37. “Documentation for package java.util.function since Java 8 (also known as Java 1.8)”. Retrieved 2021-06-16. ↩